from django.db import models
from django.core.exceptions import ValidationError
from django.utils.translation import gettext_lazy as _

# Create your models here.
def max_value(value):
    if value > 49:
        raise ValidationError(
            _('年龄不能超过50岁'),
            params={'value': value},
        )


def min_value(value):
    if value < 10:
        raise ValidationError(
            _('年龄不能小于10岁'),
            params={'value': value},
        )


class Students(models.Model):
    name = models.CharField(max_length=10, verbose_name='姓名')
    age = models.IntegerField(validators=[max_value, min_value])
